<style>
  h1::before, h1::after { content: " 1 "; display: table; }
  h2::before, h2::after { content: " 2 "; display: table-row-group; }
  h3::before, h3::after { content: " 3 "; display: table-row; }
  h4::before, h4::after { content: " 4 "; display: table-cell; }
  span {white-space: pre; }
</style>

<div><h1>Heading</h1><span>\nParagraph</span></div>
<div><h2>Heading</h2><span>\nParagraph</span></div>
<div><h3>Heading</h3><span>\nParagraph</span></div>
<div><h4>Heading</h4><span>\nParagraph</span></div>
